package cn.hfjava.kz.common.enums;

import java.util.stream.Stream;

public enum StudentStatusEnum {
    //考生状态 (0：待申报 1：已申报)

    WAIT(0,"待申报"),
    SUBMIT(1,"已申报");


    private Integer value;
    private String label;

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    StudentStatusEnum(Integer value, String label) {
        this.value = value;
        this.label = label;
    }

    public static StudentStatusEnum convert(Integer value) {
       // 1.使用增强for循环语句实现
        /*


        StudentStatusEnum sse  = null;
        for(StudentStatusEnum statusEnum : StudentStatusEnum.values()) {
            if (statusEnum.getValue().equals(value)) {
                sse = statusEnum;
                break;
            }
        }
        return sse;
         */
        //2.使用Stream API实现
        StudentStatusEnum sse = Stream.of(StudentStatusEnum.values())
                .filter(e -> e.getValue().equals(value)).findFirst().orElse(null);
        return sse;
    }

    public static StudentStatusEnum convert(String label) {
        //2.使用Stream API实现
        StudentStatusEnum sse = Stream.of(StudentStatusEnum.values())
                .filter(e -> e.getLabel().equals(label)).findFirst().orElse(null);
        return sse;
    }

}
